package com.hulei.memcached.spymemcached;

import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SpyMemcachedController {

	@Resource
	private SpyMemcachedConfig spyMemcachedConfig;

	@RequestMapping("/spyMemcachedIndex")
	public String spyMemcachedIndex() throws InterruptedException {
		/*这个过期时间单位是秒，最大值是60*60*24*30*/
		spyMemcachedConfig.getClient().set("spyMemcachedKey",1,"张三");
		System.out.println("基于spyMemcached实现，现在的值为 "+spyMemcachedConfig.getClient().get("spyMemcachedKey"));
		Thread.sleep(2000);
		System.out.println("1秒后缓存内容清除，现在的值为： "+spyMemcachedConfig.getClient().get("spyMemcachedKey"));
		return "SpyMemcached";
	}
}
